package com.itheima.commen.exception;

import com.itheima.commen.Code;
import com.itheima.commen.Result;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @Description:
 * @Version: V1.0
 */
@RestControllerAdvice
@Component
public class ProjectExceptionHandler {
    @ExceptionHandler(BusinessException.class)
    public Result doBusinessException(BusinessException ex){
        return ex.getResult();
    }

    @ExceptionHandler(Exception.class)
    public Result doException(Exception ex){
        return new Result(Code.ERROR,"网络异常,请稍后重试");
    }


}
